package cn.ad.server.persistence.dao;

import java.util.List;

import cn.ad.server.domain.ad.StrategyCrowdMap;
import cn.ad.server.persistence.typehandler.AgeEnumTypeHandler;
import cn.ad.server.persistence.typehandler.IncomeEnumTypeHandler;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import cn.ad.server.persistence.typehandler.EducationEnumTypeHandler;
import cn.ad.server.persistence.typehandler.GenderEnumTypeHandler;

@Component
public interface StrategyCrowdMapDao {

	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "gender", property = "gender"),
			@Result(column = "gender", property = "genderList",typeHandler=GenderEnumTypeHandler.class),
			@Result(column = "age", property = "age"),
			@Result(column = "age", property = "ageList",typeHandler=AgeEnumTypeHandler.class),
			@Result(column = "education", property = "education"),
			@Result(column = "education", property = "educationList",typeHandler=EducationEnumTypeHandler.class),
			@Result(column = "income", property = "income"),
			@Result(column = "income", property = "incomeList",typeHandler=IncomeEnumTypeHandler.class),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_crowd_map ")
	List<StrategyCrowdMap> findAll();

	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "gender", property = "gender"),
			@Result(column = "gender", property = "genderList",typeHandler=GenderEnumTypeHandler.class),
			@Result(column = "age", property = "age"),
			@Result(column = "age", property = "ageList",typeHandler=AgeEnumTypeHandler.class),
			@Result(column = "education", property = "education"),
			@Result(column = "education", property = "educationList",typeHandler=EducationEnumTypeHandler.class),
			@Result(column = "income", property = "income"),
			@Result(column = "income", property = "incomeList",typeHandler=IncomeEnumTypeHandler.class),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_crowd_map where update_time >= #{value} ")
	List<StrategyCrowdMap> findAfterTime(String warmUpTime);
	
	@Results(value = { @Result(column = "id", property = "id", id = true),
			@Result(column = "strategy_id", property = "strategyId"),
			@Result(column = "gender", property = "gender"),
			@Result(column = "gender", property = "genderList",typeHandler=GenderEnumTypeHandler.class),
			@Result(column = "age", property = "age"),
			@Result(column = "age", property = "ageList",typeHandler=AgeEnumTypeHandler.class),
			@Result(column = "education", property = "education"),
			@Result(column = "education", property = "educationList",typeHandler=EducationEnumTypeHandler.class),
			@Result(column = "income", property = "income"),
			@Result(column = "income", property = "incomeList",typeHandler=IncomeEnumTypeHandler.class),
			@Result(column = "create_time", property = "createTime"),
			@Result(column = "update_time", property = "updateTime") })
	@Select("select * from strategy_crowd_map where strategy_id = #{id} and status = #{status}")
	StrategyCrowdMap selectByStrategyId(@Param("id") long id, @Param("status") int status);


}
